%% [output] = Classify(features,classifier,parameters)
% 
% inputs:
%   - features: dxn (d = dimension, n = number of features)
%   - classifier: {'linear','logistic','adaboost','svm','svm-rbf'}
%   - parameters: struct that contain the parameters of the selected
%   classifier
%
% outputs:
%   - output: 1xn
%
% Matias Di Martino (2012), matiasdm@fing.edu.uy

function [output] = Classify(features,classifier,parameters)

switch lower(classifier)
    case 'linear'    
        w_linear = parameters.w;
        output = w_linear*features;
    case 'logistic'  
        w = parameters.w;
        output = w*features;
    case 'adaboost'
        [output] = ClassifyAdaboost(features,parameters);
    case 'svm'
        model = parameters;
        [~, ~, output] = svmpredict_libsvm(zeros(size(features,2),1), ...
                features', model);
        output = output';
            
    case 'svm-rbf'
        model = parameters;
        [~, ~, output] = svmpredict_libsvm(zeros(size(features,2),1), ...
                features', model);
        output = output';
                
end
% normalize between -2 and 2,
output = (output - min(output(:)) )/(max(output(:)) - min(output(:)) ) * 4 - 2;
end
